using System;
using CommonDomain;

namespace Sponsorship.Domain.PersonAssociationTemplates
{
    /// <summary>
    /// RepersonAssociations a personAssociation template in the Sponsorship domain. A personAssociation template contains default data for personAssociations.
    /// </summary>
    public class PersonAssociationTemplate : RelaxedAggregateBase
    {
        public PersonAssociationTemplate(Guid id, string associationName) : this(id, (IMemento) null)
        {
            if (id == Guid.Empty)
                throw new ArgumentException("Id must not be empty.", "id");

            RaiseEvent(new PersonAssociationTemplateEntered(id, associationName));
        }

        // Infrastructure constructor used by AggregateFactory
        private PersonAssociationTemplate(Guid id, IMemento snapshot)
        {
            if (snapshot != null)
                throw new NotSupportedException("This class does not support snapshots.");
            Id = id;
        }

        public void Change(string associationName)
        {
            RaiseEvent(new PersonAssociationTemplateChanged(Id, associationName));
        }

        public void Delete()
        {
            RaiseEvent(new PersonAssociationTemplateDeleted());
        }

        protected override IMemento GetSnapshot()
        {
            throw new NotSupportedException("This class does not support snapshots.");
        }
    }
}